/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.translate;

import com.google.api.translate.Language;
import com.google.api.translate.Translate;

/**
 * 
 * @author zgh
 */
public class TranslateApiTest {

	public static void main(String[] args) {
		// Translate.setHttpReferrer("http://www.boling.cn");
		/*
		 * 第一个参数：要翻译的内容 第二个参数：翻译内容原始的语言 第三个参数：翻译内容要得到结果的语言
		 */
		// 翻译速度大约0.28s/per
		// String translatedText = "";
		// try {
		// translatedText = Translate.execute("I am a chinese.",
		// Language.ENGLISH, Language.CHINESE_SIMPLIFIED);
		// } catch (Exception ex) {
		// }
		// System.out.println(translatedText);
		// 调用翻译只需以下两行代码
		// Translate.setHttpReferrer("http://www.boling.cn");
		// String translatedText = Translate.execute("I am a chinese.",
		// Language.ENGLISH, Language.CHINESE_SIMPLIFIED);
		String[] strArray = { "理财", "电脑/网络", "游戏", "文学艺术", "游戏大全", "医疗健康",
				"服饰/美容/减肥/化妆", "购车养车", "人物", "烦恼", "电子数码", "文理学科", "品味生活",
				"资源共享", "情感心绪", "体育运动", "教育科学", "数码世界", "车辆服务", "工作职场", "社会人文",
				"商业经济", "58站务" };
		String[] str1 = { "社会人文", "人文社会", "休闲娱乐", "娱乐休闲", "医疗健康", "医疗保健",
				"体育/运动", "理财", "商业/理财", "便民服务" };
		String[] test = { "活动/演出", "旅游/景点","收藏","音乐","明星","影视" };// ,"搬家物流","维修服务"

		String[] strTran = null;
		Translate.setHttpReferrer("http://www.boling.cn");
		try {
			strTran = Translate.execute(test, Language.CHINESE_SIMPLIFIED,
					Language.ENGLISH);
		} catch (Exception e) {
			e.printStackTrace();
		}

		for (int i = 0; i < strTran.length; i++) {
			System.out.println(strTran[i]);
		}

	}
}
